//
//  balanceViewController.m
//  lmq
//
//  Created by 马田成 on 2017/3/14.
//  Copyright © 2017年 yuanxin. All rights reserved.
//

#import "balanceViewController.h"
#import "cashViewController.h"
#import "EditMyBankCardViewController.h"
@interface balanceViewController ()
@property (weak, nonatomic) IBOutlet UIButton *historyTX;

@end

@implementation balanceViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"我的余额";
    [self creationData];
    self.historyTX.hidden = YES;
    
    // Do any additional setup after loading the view from its nib.
}
//balance  wit_money

- (void)creationData{

    NSMutableDictionary *productParams=[[NSMutableDictionary alloc]init];
    NSString *tokenStr=[PublicFunction getConfigWithKey:@"token"];
    NSString *memberId = [PublicFunction getConfigWithKey:@"uid"];
    [productParams setValue:tokenStr forKey:@"token"];
//    [productParams setValue:@"1" forKey:@"type"];
    [productParams setValue:memberId forKey:@"member_id"];
    
    [[MNetworkHandler sharedInstance]conURL:Home_TheBalanceOf
                                networkType:NetWorkPOST
                                     params:productParams
                                   delegate:nil
                                    showHUD:NO
                               successBlock:^(id returnData) {
                                   if ([[returnData objectForKey:@"code"]intValue]==1) {
                                       
                                       NSDictionary *dict1=[returnData objectForKey:@"data"];
                                       ;
                                       NSLog(@"aaaaaaaaaa%@", dict1);

                                       self.MyTheBalanceOf.text = [NSString stringWithFormat:@"%@", [dict1 objectForKey:@"balance"]];
                                       
                                       NSString *str22 = @"历史累计奖励¥";
                                       
                                       
                                     NSString *str = [NSString stringWithFormat:@"%@", [dict1 objectForKey:@"wit_money"]];
                                       self.historyLabel.text = [str22 stringByAppendingString:str];
                                       
                                   }
                                   else {
                                       [PublicFunction showAlert:nil message:[returnData objectForKey:@"msg"] duration:5.0f];
                                   }
                               } failureBlock:^(NSError *error) {
                                   NSLog(@"%@",error);
                                   [PublicFunction showAlert:nil message:@"没有连接网络" duration:10.0f];
                               }];

    

}
- (IBAction)withdrawal:(UIButton *)sender {
    
    NSMutableDictionary *productParams=[[NSMutableDictionary alloc]init];
    NSString *tokenStr=[PublicFunction getConfigWithKey:@"token"];
    [productParams setValue:tokenStr forKey:@"token"];
    [[MNetworkHandler sharedInstance]conURL:My_WithdrawalsIndex
                                networkType:NetWorkPOST
                                     params:productParams
                                   delegate:nil
                                    showHUD:NO
                               successBlock:^(id returnData) {
                                   if ([[returnData objectForKey:@"code"]intValue]==1) {
                                       
                                       cashViewController *vc = [[cashViewController alloc] init];
                                       [self.navigationController pushViewController:vc animated:YES];
                                       
                                   }
                                   else {
                                       
                                       
                                       EditMyBankCardViewController *vc = [[EditMyBankCardViewController alloc] init];
                                       vc.hidesBottomBarWhenPushed = YES;
                                       [self.navigationController pushViewController:vc animated:YES];
                                       
                                       
                                       [PublicFunction showAlert:nil message:[returnData objectForKey:@"msg"] duration:5.0f];
                                   }
                               } failureBlock:^(NSError *error) {
                                   NSLog(@"%@",error);
                                   [PublicFunction showAlert:nil message:@"没有连接网络" duration:10.0f];
                               }];

    
    
    
}
//- (IBAction)withdrawalHistory:(UIButton *)sender {
//    
//    
//}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
